import numpy as np
from sklearn.datasets import load_wine
from sklearn.preprocessing import StandardScaler


def scaler(data):
    '''
    返回标准化后的红酒数据
    :param data: 红酒数据对象
    :return: 标准化后的红酒数据，类型为ndarray
    '''
    scaler1 = StandardScaler()
    return scaler1.fit_transform(data['data'])
    


wine_dataset = load_wine()

scaler1 = StandardScaler()
answer = scaler1.fit_transform(wine_dataset['data'])

result = scaler(wine_dataset)

diff = np.sum(np.square(result-answer))

if diff < 0.1:
    print('标准化成功')
else:
    print('你的结果与答案的L2误差为%.6f' % diff)

